/*
 * @Description: 
 * @Author: rendc
 * @Date: 2025-08-12 14:16:12
 * @LastEditors: rendc
 * @LastEditTime: 2025-08-12 14:29:07
 */

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@SuppressWarnings("unchecked")
public class Test06 {

  public static void main(String[] args) {
    List list1 = new ArrayList();
    List<Integer> list2 = new ArrayList<>();
    // list1存⼊20个随机整数
    Random random = new Random();
    while (list1.size() < 20) {
      list1.add(random.nextInt(20));
    }
    System.out.println(list1);
    System.out.println(list1.size());
    // 遍历list1
    for (Object o : list1) {
      Integer integer = (Integer) o;
      if (integer % 2 == 0) {
        list2.add(integer);
      }
    }
    // 遍历list2
    for (Integer integer : list2) {
      System.out.println(integer);
    }
    System.out.println(list2);
  }
}